<template>
  <div id="app">
    <loading v-show="LOADING"></loading>
        
    <keep-alive>
          
      <router-view v-if="$route.meta.keepAlive"></router-view>
          
    </keep-alive>
        
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>

<script>
import {mapState} from 'vuex'
import Loading from './components/loading'
import api from './api/api.js'
import wx from 'weixin-js-sdk'

export default {
  name: 'App',
  computed: {
    ...mapState([
      'LOADING'
    ])
  },
  components: {
    Loading,
  },
  created() {
    this.wxshare()
  },
  methods: {
    wxshare() {
      const url = api.getconfig + '?url=' + location.href.split("#")[0];
      this.$get(url, {})
        .then((res) => {
          if (res.data.code === 1) {
            this.newData = res.data.data
            wx.config({
              debug: false,
              appId: this.newData.appId, // 必填，公众号的唯一标识
              timestamp: this.newData.timestamp, // 必填，生成签名的时间戳
              nonceStr: this.newData.nonceStr, // 必填，生成签名的随机串
              signature: this.newData.signature,// 必填，签名
              jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline'] // 必填，需要使用的JS接口列表
            });
            wx.ready(() => {
              //分享给朋友
              wx.onMenuShareAppMessage({
                title: '飞居', // 分享标题
                desc: '满足您的理想品质生活',
                link: api.domain + '/new_zsj_frontend/', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: api.domain + '/new_zsj_frontend/zsjimg.png', // 分享图标
                type: '', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function () {
                  // 用户确认分享后执行的回调函数
                  this.$router.push({path: '/mine', query: {}})
                },
                cancel: function () {
                  // 用户取消分享后执行的回调函数
                  // alert('cancel')
                  _this.fetchData()
                }
              })
              // 朋友圈
              wx.onMenuShareTimeline({
                title: '飞居', // 分享标题
                desc: '满足您的理想品质生活',
                link: api.domain + '/new_zsj_frontend/', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: api.domain + '/new_zsj_frontend/zsjimg.png', // 分享图标
                success: function () {
                  // 用户确认分享后执行的回调函数
                  this.$router.push({path: '/mine', query: {}})
                },
                cancel: function () {
                  // 用户取消分享后执行的回调函数
                  this.fetchData()
                }
              })
            })
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
  }
}
</script>

<style>
body {
  background: #f7f6fb;
}

* {
  padding: 0;
  margin: 0;
}

ul, ol {
  list-style: none;
}

a {
  text-decoration: none;
}

#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: .28rem;
  background-color: #fff;
  min-height: 100vh;
  /* overflow: hidden; */
}

.van-field__control:disabled {
  color: #000 !important;
  /* font-weight: bold; */
}

input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
  color: #969799;
}

.van-image-preview__overlay {
  background-color: rgba(0, 0, 0, 1);
}

.noticeDetail img, .guideDetail img {
  width: 100% !important;
  height: 100% !important;
}

.header-wrap {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 888;
  background: #fff;
  color: #000;
  display: flex;
  font-weight: bold;
  width: 100%;
  height: 1rem;
  line-height: 1rem;
}

.header-wrap .iconback {
  font-size: .5rem;
  margin-left: .35rem;
}

.header-wrap .iconseach {
  font-size: .38rem;
  margin-right: .4rem;
}

.header-wrap-left {
  flex: 1;
}

.header-wrap-text {
  flex: 3;
  font-size: .32rem;
  text-align: center;
}

.header-wrap-right {
  text-align: right;
  flex: 1;
}

.describe p, .describe span {
  font-size: .28rem !important;
  text-indent: 0 !important;
}
</style>
